package com.djhu.newscollector.crawel.core;

import com.djhu.newscollector.core.worker.Worker;
import com.djhu.newscollector.crawel.base.Crawler;
import com.djhu.newscollector.crawel.imp.dispacth.JmsJobDispatcher;
import com.djhu.newscollector.crawel.imp.holder.RedisJobHolder;
import com.djhu.newscollector.crawel.imp.wangyi.WangyiProcessMatcher;
import com.djhu.newscollector.crawel.imp.worker.MongoService;
import com.djhu.newscollector.crawel.imp.worker.WangyiNewsWorker;

import java.net.UnknownHostException;
import java.util.List;

/**
 * Created by zw on 2018/2/11.
 */
public class News extends Url{
    private String title;
    private String date;

    private List<String> keywords;
    private String keyword;

    private String source;
    private String type;


    public static void main(String[] args) throws UnknownHostException {
        JmsJobDispatcher dispatcher = new JmsJobDispatcher("failover:(tcp://192.168.130.192:61616)","news");
        RedisJobHolder redisJobHolder = new RedisJobHolder("192.168.130.192",6379,"hiup");

        //Worker worker = new Crawler.PrintWorker();

        MongoService mongoService = new MongoService("192.168.130.192",27017,"news");


        WangyiProcessMatcher processMatcher = new WangyiProcessMatcher();
        processMatcher.setJobDispatcher(dispatcher);
        processMatcher.setJobHolder(redisJobHolder);
        processMatcher.setMongoService(mongoService);

        WangyiNewsWorker worker = new WangyiNewsWorker();
        worker.setProcessMatcher(processMatcher);


        Crawler crawler = new Crawler();
        crawler.setJobDispatcher(dispatcher);
        crawler.setJobHolder(redisJobHolder);
        crawler.setWorker(worker);

        crawler.process(null);

//        for (int i = 1;i<100;i++){
//            Crawler.PrintJob printJob = new Crawler.PrintJob(String.valueOf(i));
//            dispatcher.retJob(printJob);
//        }



    }

}
